﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using ConsoleApp12.Model;

namespace ConsoleApp12
{
    public class Window
    {
        public static void Run()
        {
            var model = Add(5, 2).ToModel<InfoModel>();

            InfoModel input = new InfoModel();
            input.Index = 3;
            input.Test = 4.0;
            input.Name = "test";

            var outputModel = Input(input.ToIntPtr()).ToModel<InfoModel>();
            if (outputModel.Test == input.Index + input.Test)
            {
                Console.WriteLine("True");
            }
        }

        [DllImport("libcommon", EntryPoint = "add", CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr Add(int a, int b);

        [DllImport("libcommon", EntryPoint = "input", CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr Input(IntPtr model);
    }
}
